package com.hundredapp.oa.domain;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * OaUser entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "oa_user", catalog = "oa_demo", uniqueConstraints = @UniqueConstraint(columnNames = "username"))
public class OaUser implements java.io.Serializable {

	// Fields

	private Integer id;
	private String username;
	private String password;
	private String displayName;
	private Integer sex;
	private Integer status;
	private String phone;
	private String telephone;
	private Integer createUserId;
	private Timestamp createTime;
	private List<OaClass> oaClassesForAssistant = new ArrayList<OaClass>(0);
	private List<OaReserve> oaReserves = new ArrayList<OaReserve>(0);
	private List<OaRole> oaRoles = new ArrayList<OaRole>(0);
	private List<OaClass> oaClassesForBishop = new ArrayList<OaClass>(0);

	// Constructors

	/** default constructor */
	public OaUser() {
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "username", unique = true, nullable = false, length = 45)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "password", length = 45)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "display_name", length = 45)
	public String getDisplayName() {
		return this.displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	@Column(name = "sex")
	public Integer getSex() {
		return this.sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "phone", length = 45)
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "telephone", length = 45)
	public String getTelephone() {
		return this.telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	@Column(name = "create_user_id")
	public Integer getCreateUserId() {
		return this.createUserId;
	}

	public void setCreateUserId(Integer createUserId) {
		this.createUserId = createUserId;
	}

	@Column(name = "create_time", length = 19)
	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	@OneToMany(cascade ={CascadeType.REFRESH,CascadeType.MERGE,CascadeType.PERSIST}, fetch = FetchType.LAZY, mappedBy = "oaUserByAssistant")
	public List<OaClass> getOaClassesForAssistant() {
		return this.oaClassesForAssistant;
	}

	public void setOaClassesForAssistant(List<OaClass> oaClassesForAssistant) {
		this.oaClassesForAssistant = oaClassesForAssistant;
	}

	@OneToMany(cascade = {CascadeType.REFRESH,CascadeType.MERGE,CascadeType.PERSIST}, fetch = FetchType.LAZY, mappedBy = "oaUser")
	public List<OaReserve> getOaReserves() {
		return this.oaReserves;
	}

	public void setOaReserves(List<OaReserve> oaReserves) {
		this.oaReserves = oaReserves;
	}

	@ManyToMany(cascade ={CascadeType.REFRESH,CascadeType.MERGE,CascadeType.PERSIST}, fetch = FetchType.LAZY)
	@JoinTable(name = "oa_user_role", catalog = "oa_demo", joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "role_id", nullable = false, updatable = false) })
	public List<OaRole> getOaRoles() {
		return this.oaRoles;
	}

	public void setOaRoles(List<OaRole> oaRoles) {
		this.oaRoles = oaRoles;
	}

	@OneToMany(cascade ={CascadeType.REFRESH,CascadeType.MERGE,CascadeType.PERSIST}, fetch = FetchType.LAZY, mappedBy = "oaUserByBishop")
	public List<OaClass> getOaClassesForBishop() {
		return this.oaClassesForBishop;
	}

	public void setOaClassesForBishop(List<OaClass> oaClassesForBishop) {
		this.oaClassesForBishop = oaClassesForBishop;
	}

}